/**
 * @author Yaqi Zhang
 */
public class Muscle extends Spring {
    private static final double DELTA_ANGLE = 0.1;
    private double myAngle = 0;
    private double myAmplitude;

    /**
     * pass the start, end, length and kVal parameters to the super class.
     * @param start start mass
     * @param end end mass
     * @param length rest length of the muscle
     * @param kVal springy-ness of the muscle
     * @param amplitude the maximum amplitude of the muscle
     */
    public Muscle(Mass start, Mass end, double length, double kVal,
            double amplitude) {
        super(start, end, length, kVal);
        // TODO Auto-generated constructor stub
        myAmplitude = amplitude;
    }

    @Override
    public double calLength(double fixedlength) {
        return fixedlength + 2 * getIncrease();
    }

    /**
     * return the amplitude of the sin waveform.
     */
    public double getIncrease() {
        myAngle = myAngle + DELTA_ANGLE;
        double inc = myAmplitude * Math.sin(myAngle);
        return inc;
    }
}
